package com.aitaoxue.palx.ui.register;

import android.content.Intent;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;

import com.aitaoxue.palx.AppManager;
import com.aitaoxue.palx.R;
import com.aitaoxue.palx.base.BaseActivity;
import com.aitaoxue.palx.fragment.GuideFragment_1;
import com.aitaoxue.palx.fragment.GuideFragment_2;
import com.aitaoxue.palx.ui.LoginActivity;

public class GuideActivity extends BaseActivity {

	FragmentManager manager;

	private GuideFragment_1 fragment1;

	@Override
	protected boolean hasBackButton() {
		return true;
	}

	@Override
	protected int getActionBarTitle() {
		return R.string.guide;
	}

	@Override
	protected int getLayoutId() {
		return R.layout.activity_guide;
	}

	@Override
	public void onClick(View v) {

	}

	@Override
	public void initView() {
		manager = getSupportFragmentManager();
		FragmentTransaction transaction = manager.beginTransaction();
		fragment1 = new GuideFragment_1();
		transaction.add(R.id.container, fragment1);
		transaction.commit();
		
		AppManager.getAppManager().addActivity(this);
	}

	@Override
	public void initData() {

	}

	public void goToNextFragment() {
		FragmentTransaction tr = manager.beginTransaction();
		tr.hide(fragment1);
		tr.add(R.id.container, new GuideFragment_2());
		tr.addToBackStack(null);
		tr.commit();
	}
	
	@Override
	public void onBackPressed() {
		if(manager.getBackStackEntryCount()==0){
			//进入到首页
			AppManager.getAppManager().finishAllActivity();
			startActivity(new Intent(this, LoginActivity.class));
		}else{
			super.onBackPressed();
		}
	}
}







